Re: [SQL] Order by - Mailing list pgsql-sql

From Herouth Maoz
Subject Re: [SQL] Order by
Date
Msg-id l03130305b37af76d6120@[147.233.159.109]
Whole thread Raw
In response to Re: [SQL] Order by  (wieck@debis.com (Jan Wieck))
List pgsql-sql
At 17:49 +0300 on 02/06/1999, Jan Wieck wrote:


>     GROUP BY must be  possible  in  a  view's  query  expression.
>     Without  that  views  with aggregate columns could never work
>     properly.
>
>     If I now read your above statements right, "query expression"
>     ->  "query specification" -> "table expression" also forbid's
>     GROUP BY, because it cannot occur in  a  table  expression  -
>     right?  That  means  that  a  fully SQL92 compliant DB cannot
>     support aggregates in view definitions?

No, "table expression" includes "group by" and "having", because they
define the data itself. They actually say something about the set of
tuples. Here is the "table expression" definition:

  <table expression> ::=       <from clause>       [ <where clause> ]       [ <group by clause> ]       [ <having
clause>]
 

Here is the "query specification":
  <query specification> ::=       SELECT [ <set quantifier> ] <select list> <table expression>
  <select list> ::=         <asterisk>       | <select sublist> [ { <comma> <select sublist> }... ]
  <select sublist> ::=         <derived column>       | <qualifier> <period> <asterisk>
  <derived column> ::= <value expression> [ <as clause> ]
  <as clause> ::= [ AS ] <column name>

Finally, if you wondered where the syntax allows for unions and such like
for the definition of a view, here it is:
  <query expression> ::=       <non-join query expression>     | <joined table>
   <non-join query expression> ::=       <non-join query term>     | <query expression> UNION  [ ALL ] [ <corresponding
spec>] <query term>
 
     | <query expression> EXCEPT [ ALL ] [ <corresponding spec> ] <query term>

   <query term> ::=       <non-join query term>     | <joined table>
   <non-join query term> ::=       <non-join query primary>     | <query term> INTERSECT [ ALL ] [ <corresponding spec>
]<query primary>
 

   <query primary> ::=       <non-join query primary>     | <joined table>
   <non-join query primary> ::=       <simple table>     | <left paren> <non-join query expression> <right paren>
   <simple table> ::=       <query specification>     | <table value constructor>     | <explicit table>
   <explicit table> ::= TABLE <table name>
   <corresponding spec> ::=     CORRESPONDING [ BY <left paren> <corresponding column list> <right
paren> ]

   <corresponding column list> ::= <column name list>

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma




pgsql-sql by date:

Previous
From: wieck@debis.com (Jan Wieck)
Date:
Subject: Re: [SQL] Order by
Next
From: Stuart Rison
Date:
Subject: RE: [GENERAL][SQL] 'denormalising' with a select